#####################
REPLICATION MATERIALS
#####################

AUTHORS: Neunhoeffer, Marcel; Stoetzer, Lukas F.; Gschwend, Thomas; Munzert, Simon; Sternberg, Sebastian
ARTICLE: "Forecasting Elections in Multi-Party Systems: A Bayesian Approach Combining Polls and Fundamentals"
JOURNAL: Political Analysis
UPDATED: July 2, 2018
CONTACT: marcel.neunhoeffer@gess.uni-mannheim.de; lukas.stoetzer@uzh.ch


INSTRUCTIONS:

To replicate the analysis, you first have to download all 9 files (besides this README) from the Dataverse. 

Due to dataverse file upload size restrictions it is necessary to move some files (Steps 1 to 3) prior to the actual replication (Step 4). 

1. Unzip „pa_multi-party_forecasting.zip“ - This will be the main folder.

2. Unzip all the „ger_xxxx(_x)“ folders and move the content of each (in total 50 .RDS files) of the folders into „pa_multi-party_forecasting/output/ger/draws/combined_model“.

3. Also move „res_brw_2017_2.RDS“ into „pa_multi-party_forecasting/output/ger/draws/combined_model“.

4. Now you can get started by opening „Replication.Rmd“. (Which contains further information about the replication files.)

SOFTWARE:

To open and run the „Replication.Rmd“ file you will need a current version of RStudio (we used RStudio 1.1.383). All the R packages needed for replication will be automatically installed and loaded when running „Replication.Rmd“.

SOFTWARE ENVIRONMENT:

platform 			x86_64-apple-darwin15.6.0 
arch 				x86_64
os 					darwin15.6.0
system 				x86_64, darwin15.6.0
status 
major 				3
minor 				4.3	
year 				2017
month 				11
day					30
svn rev 			73796
language 			R
version.string 		R version 3.4.3 (2017-11-30)
nickname 			Kite-Eating Tree

RStudio				1.1.383

R PACKAGES:

- haven
- lubridate
- stringr
- ggplot
- dl
- plyr
- dplyr
- magrittr
- broom
- tidyr
- stringr
- reshape2
- rjags
- runjags
- readr
- rvest
- mcmcplots
- parallel
- rstan
- shinystan
- superdiag
- xtable
- knitr

DATAVERSE STRUCTURE (after Steps 1 to 3):

 • code
	– model_code -> Contains the Stan model files
	– R -> Contains the R code necessary for full Replication 
• data
	– ger -> Contains all input data for Germany (Polls and Structural Predictors) 
		∗ Polls
		∗ Structural
		∗ structural_inits
	– nz -> Contains all input data for New Zealand (Polls and Structural Predictors)
		∗ Polls
		∗ Structural
		∗ structural_inits
• output
	– ger -> Contains the output of the models for Germany
		∗ draws 
		* forecasts
		∗ plots -> Running the whole thing from scratch will save some plots here.
	– nz -> Contains the output of the models for New Zealand
		∗ draws
		∗ forecasts 
		∗ plots -> Running the whole thing from scratch will save some plots here.
	- paper -> Contains all the Plots and Tables from the paper
• Replication.Rmd -> This file, replicates everything in the article




RUNNING TIMES:

Setup: MacBook Air 2014, 1.4 GHz Intel Dual-Core i5, 8GB RAM

- Replication of results given MCMC draws with "Replication.Rmd": ~ 3 minutes

- Re-running the stan models (one country, one election, one cutoff): ~ 180 minutes = 3 hours (--> approx. time for the results in the paper (2 countries, 5/3 elections, 7 cutoffs per election = 56 models) 56 * ~180 minutes ~ 10,080 minutes = 168 hours = 7 days)

NOTE:
If you have any further questions concerning the replication materials, please send an email to Marcel Neunhoeffer or Lukas F. Stoetzer. 
